﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Security;
using System.Web.UI.WebControls;
using Database;
using Business;

namespace DT5_Anh09110006_Hung09110044_Vu09110157.QuanLy
{
    public partial class QuanLyTaiKhoan : System.Web.UI.Page
    {
        Business.QuanLyTaiKhoan qltaikhoan = new Business.QuanLyTaiKhoan();
        String tendangnhap;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Username"] != null)
            {
                tendangnhap = Session["Username"].ToString();
            }
        }

        protected void btnCapNhatLopHoc_Click(object sender, EventArgs e)
        {

            if (tendangnhap != null)
            {
                if (qltaikhoan.kiemtranguoidung(tendangnhap, txtMatKhau.Text))
                {
                    qltaikhoan.thaydoimatkhau(tendangnhap, txtMatKhauMoi.Text);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "redirectMe", "alert('Mật khẩu đã được thay đổi');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "redirectMe", "alert('Mật khẩu cũ không chính xác');", true);
                }
            }
        }

        protected void ddlchucnang_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlchucnang.SelectedIndex == 0)
            {
                chucnang0.Visible = true;
                chucnang1.Visible = false;
            }
            if (ddlchucnang.SelectedIndex == 1)
            {
                chucnang0.Visible = false;
                chucnang1.Visible = true;
                NhanVien nv = qltaikhoan.laythongtinnguoidung(tendangnhap);
                lblMaNV.Text = nv.MaNV;
                lblHoTenNV.Text = nv.HoTenNV;
                lblNgaySinh.Text = nv.NgaySinh.Value.ToString("MM/dd/yyyy");
                lblDiaChiNV.Text = nv.DiaChi;
                lblGioiTinh.Text = nv.GioiTinh;
                lblDienThoaiNV.Text = nv.DienThoai;
                lblQuanLy.Text = nv.MaNQL;
                lblCMNDNV.Text = nv.CMND;
                lblEmailNV.Text = nv.Email;
            }
        }

     
    }
}